/**
 * @param {string} s
 * @return {string[]}
 */

var letterCasePermutation = function (s) {
    let res = []
    backtrack("", 0)
    function backtrack(str, index) {
        // 退出条件
        if (index === s.length) {
            res.push(str)
            return
        }
        let S = s[index]
        if ("A" <= S && S <= "Z" || "a" <= S && S <= "z") {
            let low = S.toLowerCase()
            let high = S.toUpperCase()
            backtrack(str + low, index + 1)
            backtrack(str + high, index + 1)
        } else {
            backtrack(str + S, index + 1)
        }
    }
    return res
};